﻿define(['durandal/app',
        'plugins/dialog',
        'i18n', 
        'services/config', 
        'toastr', 
        'services/layout',
        'home/demo/popup1', 
        'home/demo/popup2'], 
	function (app, dialog, i18n, config, toastr, L, popup1, popup2) {
	
    var ctor = function () {
        this.displayName = i18n.ts('cms:demo', config.app.fullname);
        this.description = 'Durandal is a cross-device, cross-platform client framework written in JavaScript and designed to make Single Page Applications (SPAs) easy to create and maintain.';
        this.features = [
            'Clean MV* Architecture',
            'JS & HTML Modularity',
            'Simple App Lifecycle',
            'Eventing, Modals, Message Boxes, etc.',
            'Navigation & Screen State Management',
            'Consistent Async Programming w/ Promises',
            'App Bundling and Optimization',
            'Use any Backend Technology',
            'Built on top of jQuery, Knockout & RequireJS',
            'Integrates with other libraries such as SammyJS & Bootstrap',
            'Make jQuery & Bootstrap widgets templatable and bindable (or build your own widgets).',
            'Clean MV* Architecture',
            'JS & HTML Modularity',
            'Simple App Lifecycle',
            'Eventing, Modals, Message Boxes, etc.',
            'Navigation & Screen State Management',
            'Consistent Async Programming w/ Promises',
            'App Bundling and Optimization',
            'Use any Backend Technology',
            'Built on top of jQuery, Knockout & RequireJS',
            'Integrates with other libraries such as SammyJS & Bootstrap',
            'Make jQuery & Bootstrap widgets templatable and bindable (or build your own widgets).',
            'Clean MV* Architecture',
            'JS & HTML Modularity',
            'Simple App Lifecycle',
            'Eventing, Modals, Message Boxes, etc.',
            'Navigation & Screen State Management',
            'Consistent Async Programming w/ Promises',
            'App Bundling and Optimization',
            'Use any Backend Technology',
            'Built on top of jQuery, Knockout & RequireJS',
            'Integrates with other libraries such as SammyJS & Bootstrap',
            'Make jQuery & Bootstrap widgets templatable and bindable (or build your own widgets).',
            'Clean MV* Architecture',
            'Built on top of jQuery, Knockout & RequireJS',
            'Integrates with other libraries such as SammyJS & Bootstrap',
            'Make jQuery & Bootstrap widgets templatable and bindable (or build your own widgets).'
        ];
        this.actionsPopup = [
            { id: 'viewPopup1', name: 'Popup 1', callback: viewPopup1.bind(this) },
            { id: 'viewPopup2', name: 'Popup 2', callback: viewPopup2.bind(this) }
        ];

        this.test1 = test1;
        this.test2 = test2;
        this.test3 = test3;
        this.test4 = test4;
        this.test5 = test5;
        this.test6 = test6;
        this.test7 = test7;
    };

    ctor.prototype.compositionComplete = viewCompositionComplete;

    return ctor;
    
    function viewCompositionComplete(view) {
    	L.relayout();
    }
    
    function test1() {toastr.success('Are you the six fingered man?', 'Inigo Montoya');}
    function test2() {toastr.info('Are you the six fingered man?');}
    function test3() {toastr.warning('My name is Inigo Montoya. You Killed my father, prepare to die!');}
    function test4() {toastr.success('Have fun storming the castle!', 'Miracle Max Says');}
    function test5() {toastr.error('I do not think that word means what you think it means.', 'Inconceivable!');}
    function test6() {app.showMessage('This is a message.', 'Demo');}
    function test7() {app.showMessage('You have unsaved data. Are you sure you want to close?', 'Unsaved Data', ['Yes', 'No']);}
    
    function viewPopup1() {
       	dialog.showBS3Dialog(new popup1);
       	L.relayout();
    }

	function viewPopup2() {
	   	dialog.showBS3Dialog(new popup2);
	   	L.relayout();
	}
    
});